package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.io.StringBufferInputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.*;

@Getter@Setter
@JsonIgnoreProperties("handler")
public class Review extends BaseDomain{

    private User user;//用户

    private Long essayId;//文章id

    private Long authorId;//作者id

    private Integer state;//文章类型

    private String review;//讨论正文

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;//创建时间
    //评论的标题
    private String title;
    //评论者的名字
    private String nickName;
    //是否已读
    private Integer readed;

    private List<Reply> replyBody = new ArrayList<>();

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        if (user != null){
            map.put("userId", user.id);
        }
        return JSONUtil.toJSONString(map);
    }
}